Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amrex::Finalize() w/ gc.collect() #83

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Oct 17, 2022

When calling amrex.finalize(), first call the Python garbage collector. This is purely a bandage to make usage like this easy:

import amrex

amrex.initialize([])
mfab = amrex.MultiFab( ... )
del mfab

# the moment that mfab gets deleted is Python implementation
# dependent

# we just call gc.collect() now, so that users do not need to worry
# also, finalize() is definitely the location where we can spend some cleanup time
amrex.finalize()

Respect the Python standard guarantees without furhter headache, by running an explicit call to the garbage collector.

Previously, this was only working with CPython, but alternative implementations like PyPy might delay the true free due to time based memory collection approaches.

Related to #81

When calling `amrex.finalize()`, first call the Python
garbage collector. This is purely a bandage to make
usage like this easy:

```py
import amrex

amrex.initialize([])
mfab = amrex.MultiFab( ... )
del mfab
amrex.finalize()
```

Respect the Python standard guarantees without furhter headache,
by running an explicit call to the garbage collector.

Previously, this was only working with CPython, but alternative
implementations like PyPy might delay the true free due to time
based memory collection approaches.
@ax3l ax3l added the enhancement New feature or request label Oct 17, 2022
@ax3l ax3l merged commit 86273bd into AMReX-Codes:development Oct 17, 2022
@ax3l ax3l deleted the finalize-prep-w-gc branch October 17, 2022 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant